<?php
    include_once("mysql_conn.php");
    session_start();
    $username = ($_POST['username'] == NULL) ? '' : $_POST['username'];
    $password = ($_POST['password'] == NULL) ? '' : $_POST['password'];
    $conn = new mysql_conn();
    $sql = "select * from user where username = '" . $username . "' and password = '" . $password."'";

    $result = $conn->select($sql);
    if ($result == NULL) {
        echo "<script language='javascript'>alert('您输入错误，请重新输入！');history.back();</script>";
      exit;
    }else{
        $_SESSION['user']=$result['username'];
        $_SESSION['id']=$result['id'];
        $_SESSION['perssime']=$result['perssime'];
        if ($result['perssime']==1){
            echo "<script>alert('登录成功!');window.location='homeAdminOrders.php';</script>";
        }else {
            echo "<script>alert('登录成功!');window.location='homeCustomer.php';</script>";

        }

    }
?>
